package com.itwn.mapper;

import com.itwn.entity.Manager;
import com.itwn.vo.PermissionVo;
import org.apache.ibatis.annotations.*;

import com.itwn.vo.ManagerVo;

import java.util.Date;
import java.util.List;

@Mapper
public interface ManagerMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Manager record);


    int updateByPrimaryKey(Manager record);

    List<ManagerVo> findAllManager(@Param("userName") String userName, @Param("userCode") String userCode);

    //  插入一条管理员数据
    int insert(ManagerVo record);

    //  根据id查询出一条管理员数据
    @Select("select * from c_manager where user_code=#{userCode} ")
    Manager selectByPrimaryKey(String userCode);

    //  向管理员和角色中间表插入一条数据
    @Insert("insert into c_manager_role (manager_id,role_id,insert_time,update_time) values (#{managerId},#{roleId},#{insertTime},#{updateTime});")
    int insertManagerRole(@Param("managerId") Long managerId, @Param("roleId") Long roleId,
                          @Param("insertTime") Date insertTime, @Param("updateTime") Date updateTime);

    int updateManager(ManagerVo managerVo);

    @Delete("delete from c_manager_role where manager_id=#{managerId} and role_id=#{roleCode} ")
    int deleteManagerRoel(@Param("managerId") Long managerId, @Param("roleCode") Long roleCode);

    @Delete("delete from c_manager where id=#{id} ")
    int deleteById(Long id);

    Manager selectByCode(@Param("code") String code);

    List<PermissionVo> selectPermissionByCode(@Param("userCode") String userCode);
}